﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Gmis.Public;
using System.Text;

namespace Gmis.Web.Manage.Affairs
{
    public partial class SocialAssistanceEdit : System.Web.UI.Page
    {
        public string action = ""; //动作
        public string sId = "";// 传入的id  空代表新增 有值代表修改       
        public Model.SocialAssistance model = new Model.SocialAssistance();
        string sOption = "<option value='{0}' {1}>{2}</option>";

        protected void Page_Load(object sender, EventArgs e)
        {
            //传入ID 和操作
            sId = CommonFunction.getRequestValue("Id");
            action = CommonFunction.getRequestValue("action");
            if (sId != "")
            {
                BLL.SocialAssistance bll = new BLL.SocialAssistance();
                model = bll.GetModel(sId);
            }
        }

        public string GetAssistanceData(string defaultValue)
        {
            return GetOptionData(typeof(Model.Assistances), defaultValue);
        }

        public string GetPoliticsData(string defaultValue)
        {
            return GetOptionData(typeof(Model.Politics), defaultValue);
        }

        public string GetOptionData(Type type, string defaultValue)
        {
            StringBuilder sb = new StringBuilder();
            int i = 0;
            foreach (string s in Enum.GetNames(type))
            {
                string selected = "";
                if (string.IsNullOrEmpty(defaultValue) && i == 0)
                    selected = "selected";
                else if (s.Trim() == defaultValue.Trim())
                    selected = "selected";
                sb.Append(string.Format(sOption, s, selected, s));
                i++;
            }
            return sb.ToString();
        }
    }
}